package com.gitee.wsl.compose.ui.button

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.hoverable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsHoveredAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ExitToApp
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.gitee.wsl.compose.ui.base.Button


//https://uiverse.io/vinodjangid07/thin-duck-22
//@Composable
//fun LogoutSample() {
//    Box(
//        modifier = Modifier
//            .fillMaxSize()
//            .background(Color(232, 232, 232))
//            .border(1.dp, Color.Green),
//        contentAlignment = Alignment.Center
//    ) {
//        Logout()
//    }
//}


@Composable
fun Button.AnimatedText(
    modifier: Modifier = Modifier,
    text: String ,
    icon: ImageVector = Icons.AutoMirrored.Outlined.ExitToApp,
    onClick: () -> Unit = {}
) {
    val interactionSource = remember { MutableInteractionSource() }
    val hovered by interactionSource.collectIsHoveredAsState()
    val horizontalPadding by animateDpAsState(if (hovered) 18.dp else 12.dp)
    FloatingActionButton(
        onClick = onClick,
        containerColor = Color(255, 65, 65),
        modifier = modifier.hoverable(interactionSource)
    ) {
        Row(
            modifier = Modifier.padding(horizontal = horizontalPadding),
            verticalAlignment = Alignment.CenterVertically,
            horizontalArrangement = Arrangement.SpaceEvenly
        ) {
            Icon(
                icon,
                contentDescription = null,
                tint = Color.White
            )
            AnimatedVisibility(hovered) {
                Text(
                    text = text,
                    color = Color.White,
                    fontSize = 15.sp,
                    fontWeight = FontWeight.Bold,
                    fontFamily = FontFamily.Cursive,
                    modifier = Modifier.padding(horizontal = 5.dp, vertical = 3.dp)
                )
            }
        }
    }
}
